package com.example.shengyin.frontController;

import com.example.shengyin.entity.Shop;
import com.example.shengyin.service.ShopService;
import com.example.shengyin.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("front/shop")
@Validated
//@CrossOrigin(origins = "*", maxAge = 3600,allowCredentials="true")
@Api(tags = "ShopFrontController", description = "门店")
public class FrontShopController {

    @Autowired
    private ShopService service;

    @ApiOperation("单个查找，传城市的id获得城市的所有门店信息")
    @GetMapping(value = "select/{id}")
    public Result select(@PathVariable(value = "id") Long id)
    {
        List<Shop> select = service.select(id);
        if(select==null)
            return Result.error("没有找到数据");
        return Result.success(select);
    }

}
